<template>
  <div>
    <header class="site-header jumbotron">
      <div class="container">
        <div class="row">
          <div class="col-xs-12">
            <h1>请发表对Vue的评论</h1>
          </div>
        </div>
      </div>
    </header>

    <div class="container">
      <!--评论添加，传值给子组件-->
      <CommentAdd :comments="comments"  ref="userComment"/>
      <!--评论列表,传值给子组件-->
      <CommentList :comments="comments" />
    </div>
  </div>
</template>

<script>
import CommentAdd from "./components/comment-add";
import CommentList from "./components/comment-list";
import {mapState} from "vuex";

export default {
  name: "App",
  components: { CommentAdd, CommentList },
  computed:{
    ...mapState(['comments'])
  },

  mounted(){
    //访问根实例
    console.log("this.$root=",this.$root);
    //父组件通过$refs访问子组件的实例
    console.log("this.$refs=",this.$refs.userComment.test());

    console.log(this.$store,"==============");
  }
};
</script>

<style></style>
